package com.whj.controller;

import com.whj.domain.constants.SystemConstants;
import com.whj.domain.dto.AddCommentDTO;
import com.whj.domain.entity.Comment;
import com.whj.domain.response.ResponseResult;
import com.whj.service.CommentService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther: wanghaijun
 * @Date: 2023/5/25 - 05 - 25 - 9:29 
 * @Description: com.whj.controller
 */

@RestController
@RequestMapping("/comment")
@Api(tags = "评论", description = "评论相关的接口")
public class CommentController {

    @Autowired
    private CommentService commentService;

    /**
     * 查询评论信息
     * @param articleId 文章id
     * @param pageNum 分页数量
     * @param pageSize 分页大小
     * @return
     */
    @GetMapping("/commentList")
    public ResponseResult commentList(Long articleId, Integer pageNum, Integer pageSize) {
        return commentService.commentList(SystemConstants.ARTICLE_COMMENT,articleId, pageNum, pageSize);
    }

    /**
     * 用户发表评论
     * @param addCommentDTO 发表评论的实体类
     * @return
     */
    @PostMapping
    public ResponseResult addComment (@RequestBody AddCommentDTO addCommentDTO){
        return commentService.addComment(addCommentDTO);
    }

    @GetMapping("/linkCommentList")
    public ResponseResult linkCommentList(Integer pageNum, Integer pageSize){
        return commentService.commentList(SystemConstants.LINK_COMMENT,null,pageNum,pageSize);
    }
}
